package com.twu.biblioteca;

import java.io.PrintStream;

/**
 * Created by thoughtworker on 1/17/14.
 */
public class BookReturner implements LibraryAction {

    Library library;
    PrintStream printStream;

    public BookReturner(PrintStream printStream, Library library){
        this.printStream = printStream;
        this.library = library;
    }

    public void performAction() {

    }

    public void returnBook(String bookTitle) {
        for(LibraryBook book : library){
            if (bookTitle.equals(book.toString()) && !book.isAvailable()){
                book.makeAvailable();
                book.setOwner("library");
                printStream.println("Thank you! Enjoy the book");
                return;
            }
        }
    }
}
